package com.zpark.controller;

import com.zpark.SpringConfig;
import com.zpark.pojo.Account;
import com.zpark.service.IAccountService;
import org.apache.log4j.Logger;
import com.zpark.log.Log;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import sun.applet.Main;

/**
 * @PackageName: com.zpark.controller
 * @ClassName: AccountController
 * @Description:
 * @author: RZS
 * @date: 2023/3/30  16:35
 */
public class AccountController {
    static Logger log = Logger.getLogger(AccountController.class.getName());
    public static void main(String[] args) {
        log.info("准备创建Spring容器");
        // 1、获取容器对象
        ApplicationContext app = new AnnotationConfigApplicationContext(SpringConfig.class);
        // 2、根据id获取bean
        IAccountService service = app.getBean("accountService", IAccountService.class);
        // 3、使用bean
        System.out.println(service.findAll());
        log.info("执行查询方法");
        System.out.println(service.findById(2));

        // 添加数据
        Account account = new Account();
        account.setId(5);
        account.setUid(50);
        account.setMoney(6666.6);

//        service.add(account);

        // 修改数据
//        service.change(account);

        // 删除数据
        service.remove(5);

    }
}
